package thread.mailbox;

import java.util.Random;

public class TukangPos implements Runnable{
	private KotakSurat kotakSurat;
	
	public TukangPos(KotakSurat kotakSurat){
		this.kotakSurat = kotakSurat;
	}
	
	public void antar() throws InterruptedException{
		kotakSurat.masukkan();
	}

	@Override
	public void run() {
		try {
			for(int i=0 ; i<5 ; i++){
				antar();
				System.out.println("Jumlah surat :" +kotakSurat.jumlah());
				Thread.sleep(new Random().nextInt(2000));
			}
		} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
		}
	}
		
}

